package com.zsw.exception;

import lombok.Getter;
import lombok.Setter;

/**
 * @Author sandman
 * @Date 2020-08-12
 * @Description 自定义异常类
 */
@Getter
@Setter
public class BusinessException extends RuntimeException {

    private String code;
    private String msg;

    public BusinessException(){
        super();
    }


    public BusinessException(String code,String message){
        super(message);
        setCode(code);
        setMsg(message);
    }

    public BusinessException(ResponseBaseDTO baseErrorInfo){
        super(baseErrorInfo.getMessage());
        setCode(baseErrorInfo.getCode());
        setMsg(baseErrorInfo.getMessage());
    }


    public BusinessException(ResponseBaseDTO baseErrorInfo,Throwable cause){
        super(baseErrorInfo.getMessage(),cause);
        setCode(baseErrorInfo.getCode());
        setMsg(baseErrorInfo.getMessage());
    }

    public BusinessException(String errMsg){
        super(errMsg);
        setMsg(errMsg);
    }

    public BusinessException(UserErrorEnum userErrorEnum) {
        super(userErrorEnum.getMsg());
        setCode(userErrorEnum.getCode());
        setMsg(userErrorEnum.getMsg());
    }

    public BusinessException(String errMsg, Throwable cause){
        super(errMsg,cause);
        setMsg(errMsg);
    }



}